//
//  BattleScene.h
//  fingeradvanture
//
//  Created by 8089HaiWan1 on 16/5/14.
//
//

#ifndef _BATTLE_SCENE_H_
#define _BATTLE_SCENE_H_

#include "cocos2d.h"
#include "Box2D/Box2D.h"
#include "MyContactListener.h"
#include "GLES-Render.h"
USING_NS_CC;

class BattleScene : public cocos2d::Layer
{
public:
    Node* player;
    b2World* m_world;
    MyContactListener* myContactListener;
    GLESDebugDraw* debugDraw;
public:
    ~BattleScene();
    static cocos2d::Scene* createScene();
    virtual bool init();
    virtual void update(float delta);
    // implement the "static create()" method manually
    CREATE_FUNC(BattleScene);
    
    virtual void draw(Renderer *renderer,const cocos2d::Mat4&transform,uint32_t flags);
    
    // a selector callback
    void menuCloseCallback(cocos2d::Ref* pSender);
    //创建物理世界
    void setPhyWorld(b2World* world){m_world=world;};
    //检测到碰撞的callback
    bool onContactBegin(const PhysicsContact& contact);
    //触摸事件
    bool onTouchBegan(Touch *pTouch, Event *pEvent);
    void onTouchMoved(Touch *pTouch, Event *pEvent);
    void onTouchEnded(Touch *pTouch, Event *pEvent);
    
    void heroEnter(float x, float y);
    
private:
    void registerContactListener();
    void deregisterContactListener();
};

#endif /* BattleScene_h */
